<extend name="layout/edit" />

<block name="HEADER">

</block>

<block name="CONTENT">
    <control:form id="releaseForm"/>
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
		ns.init = function(){
			
		}
		
    	//选择商户
    	ns.selectStore = function(){
    		var filter = {
	            url:"modules/common/selectStore",
	            mode:1
	        }
	        $.openIframe(filter, "选择商户",['500px', '450px']);
    	}
    	
    	//选择商户的回调
    	ns.selectStoreCallback = function(ids){
    		releaseForm.setValue('store_ids',ids);
    	}
    	
    	
        //保存
        ns.save=function(){
        	var data = releaseForm.getData();
        	if( !data ) {  return false; } 
        	if( data.start_time >= data.end_time ){
				$.alert(0,"开始时间不能大于等于结束时间！");
				return false;
			}
        	releaseForm.setValue('remain_count',  releaseForm.getValue('total_count') );
    		releaseForm.save(4).then(function(res){
    			parent.$.toast(1,'已发放到优惠券池列表中！');
    			$.close();
            });
        }
        
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>



